//
//  Name.swift
//  Automobile
//
//  Created by erkebulan elzhan on 7/27/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import Foundation


@propertyWrapper
struct Name {
    private(set) var value: String = ""
    
    var wrappedValue: String {
        get { value }
        set {
            let array = newValue.split(separator: " ")
            let surName = array[0]
            if array.count == 3 {
                value = "\(surName) \(array[1].first!).\(array[2].first!)"
            } else {
                value = "\(surName) \(array[1].first!)."
            }
        }
    }
    init(initialValue: String) {
        self.wrappedValue = initialValue
    }
}
